﻿namespace Triad.Controls
{
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.Design;
    using System.Web.UI.WebControls;
    public partial class tfComboBox 
    {
        private void RenderDesignTimeCode(HtmlTextWriter writer)
        {
            GetComboBoxPanel().RenderControl(writer);
        }

        /// <summary>
        /// Gets the design time image.
        /// </summary>
        /// <param name="item">The img.</param>
        /// <returns></returns>
        private string GetDesignTimeUrl(string item)
        {
            var webApp = (IWebApplication)Site.GetService(typeof(IWebApplication));
            IProjectItem result = webApp.GetProjectItemFromUrl(item);
            return result.PhysicalPath;

        }


        /// <summary>
        /// Applies HTML attributes and styles to render to the specified <see cref="T:System.Web.UI.HtmlTextWriter"/> object.
        /// </summary>
        /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client.</param>
        /// <remarks>
        /// Author: tim.fischer,   8/25/2008 - 1:49 PM
        /// Modified By: 
        /// </remarks>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {


            base.AddAttributesToRender(writer);
            Panel cbPanel = new Panel { Width = Width, Wrap = false };
            var cbInput = new TextBox { Width = Width, ReadOnly = true, Text = FirstItemText };
            cbPanel.Controls.Add(cbInput);
            var cbImg = new Image
            {
                Width = Unit.Pixel(17),
                Height = Unit.Pixel(17),
                ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(tfResources), tfResources.RliCBDOWN)
            };
            cbPanel.Controls.Add(cbImg);

        }

        #region Design-Time Render
        private Panel GetComboBoxPanel()
        {

            Panel cbPanel = new Panel { Width = Width, Wrap = false };
            var cbInput = new TextBox {Width = Width, ReadOnly = true, Text = FirstItemText};
            cbPanel.Controls.Add(cbInput);
            var cbImg = new Image
                            {   Width = Unit.Pixel(17),
                                Height = Unit.Pixel(17),
                                ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(tfResources), tfResources.RliCBDOWN)
                            };
            cbPanel.Controls.Add(cbImg);
            return cbPanel;
        }

        #endregion

    }
}
